
/**
 * @Project : Clion_ProgrammingExercises
 * @File : 0798
 * @Author : WangRuoyu 
 * @Date : 2023/9/13 20:27
 */

#include "iostream"

using namespace std;

const int M = 1010;
const int N = 1010;

int a[M][N];
int b[M][N];

void add(int x1, int y1, int x2, int y2, int c) {
    b[x1][y1] += c;
    b[x1][y2 + 1] -= c;
    b[x2 + 1][y1] -= c;
    b[x2 + 1][y2 + 1] += c;
}

int main() {
    int m, n, k;
    scanf("%d %d %d", &m, &n, &k);

    for (int i = 0; i < m; ++i) {
        for (int j = 0; j < n; ++j) {
            scanf("%d", &a[i][j]);
            add(i, j, i, j, a[i][j]);
        }
    }

    while (k--) {
        int x1, y1, x2, y2, c;
        scanf("%d %d %d %d %d", &x1, &y1, &x2, &y2, &c);
        add(x1 - 1, y1 - 1, x2 - 1, y2 - 1, c);
    }

    for (int i = 0; i <= m; ++i) {
        for (int j = 0; j <= n; ++j) {
            if (i == 0 || j == 0) {
                a[i][j] = 0;
            } else {
                a[i][j] = b[i - 1][j - 1] + a[i][j - 1] + a[i - 1][j] - a[i - 1][j - 1];
                printf("%d ", a[i][j]);
            }
        }
        if (i != 0) {
            puts("");
        }
    }

    return 0;
}